package helperF

import (
	"encoding/json"
	"fmt"
	"github.com/davecgh/go-spew/spew"
	"github.com/k0kubun/pp/v3"
	"os"
	"strings"
)

// PrettyPrint json格式化打印
func PrettyPrint(data interface{}) {
	enc := json.NewEncoder(os.Stdout)
	enc.SetEscapeHTML(false)
	enc.SetIndent("", "  ")
	if err := enc.Encode(data); err != nil {
		fmt.Printf("%+v\n", err)
		return
	}
}

// Dump spew.Dump的别名
func Dump(d ...interface{}) {
	spew.Dump(d...)
}

// Sdump spew.Sdump的别名
func Sdump(d ...interface{}) string {
	return spew.Sdump(d...)
}

// Pprint pp.Print的别名
func Pprint(d ...interface{}) {
	_, _ = pp.Print(d...)
}

func PrettyStringArray(arr []string) string {
	return "`" + strings.Join(arr, "`,`") + "`"
}
